<?php

namespace App\Http\Requests\System\Module;

use Illuminate\Foundation\Http\FormRequest;

class StoreResource extends FormRequest
{
	/**
	 * 定义请求授权规则
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @return bool
	 */
    public function authorize()
    {
        return false;
    }

	/**
	 * 定义表单验证规则
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @return array
	 */
    public function rules()
    {
        return [
        	'code' => 'required|unique:modules',
        	'parent_code' => 'nullable',
        	'name' => 'required',
        	'introduction' => 'required',
        	'pricing' => 'required',
        	'url' => 'nullable',
        	'icon' => 'nullable',
        	'cover' => 'nullable',
        	'status' => 'required',
        	'type' => 'required',
        	'order' => 'required',
        ];
    }

	/**
	 * 定义错误消息提示
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'code.required' => '请填写模块编码',
			'code.unique' => '您输入的编码已存在',
			'name.required' => '请填写模块名称',
			'introduction.required' => '请填写模块描述信息',
			'pricing.required' => '请填写模块价格',
			'status.required' => '请选择模块状态',
			'type.required' => '请选择模块类型',
			'order.required' => '请填写模块排序',
		];
    }
}
